#-*- coding:UTF-8 -*-
import Tkinter
from Tkinter import *

class MainFrame(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent)
        self.parent = parent
        self.initUI()

    def initUI(self):
        self.parent.title('Test_FrameSize')
        self.pack(fill=BOTH, expand=1, padx=1, pady=2)
#        Label(self, text='hello').pack()
        # TODO : 最好是让它在外面pack
        FirstFrame(self, 'blue')
        FirstFrame(self, 'red')
#        FirstFrame(self, 'blue').pack() # TODO : 容器受控件大小影响Frame的值 if没有pack_propagate
#        FirstFrame(self, 'red').pack()


class FirstFrame(Frame):
    def __init__(self, parent, bgColor):
        Frame.__init__(self, parent)
        self.parent = parent
        self.initUI(bgColor)

    def initUI(self, bgColor):
        self.config(width=200, height=200, borderwidth=2, bg=bgColor)
        # self.pack()                 # TODO : 容器内部的控件大小最大与容器一样大且容器多大，本身不会受窗口大小的影响 if 有pack_propagate
        # self.pack_propagate(0)
        self.grid()
        self.grid_propagate(1)
        Label(self, text='hello', width=10, height=300).pack() #TODO : 控件的大小可由width直接

def main():
    root = Tk()
    root.geometry('300x300')
    app = MainFrame(root)
    root.mainloop()

if __name__ == '__main__':
    main()